fix: ios build

This commit is contained in:
Kingtous 2023-04-17 19:26:39 +08:00
parent f56fc6fdb0
commit 83e63d57e1
16 changed files with 171 additions and 96 deletions

View File

@ -15,7 +15,7 @@ fn link_vcpkg(mut path: PathBuf, name: &str) -> PathBuf {
let mut target = if target_os == "macos" { let mut target = if target_os == "macos" {
if target_arch == "x64" { if target_arch == "x64" {
"x64-osx".to_owned() "x64-osx".to_owned()
} else if target_arch == "arm64"{ } else if target_arch == "arm64" {
"arm64-osx".to_owned() "arm64-osx".to_owned()
} else { } else {
format!("{}-{}", target_arch, target_os) format!("{}-{}", target_arch, target_os)

View File

@ -3,9 +3,9 @@ extern crate scrap;
use std::fs::File; use std::fs::File;
use scrap::{i420_to_rgb, Display};
#[cfg(windows)] #[cfg(windows)]
use scrap::{CapturerMag, TraitCapturer}; use scrap::{CapturerMag, TraitCapturer};
use scrap::{i420_to_rgb, Display};
fn main() { fn main() {
let n = Display::all().unwrap().len(); let n = Display::all().unwrap().len();

View File

@ -18,7 +18,7 @@ use webm::mux;
use webm::mux::Track; use webm::mux::Track;
use scrap::vpxcodec as vpx_encode; use scrap::vpxcodec as vpx_encode;
use scrap::{TraitCapturer, Capturer, Display, STRIDE_ALIGN}; use scrap::{Capturer, Display, TraitCapturer, STRIDE_ALIGN};
const USAGE: &'static str = " const USAGE: &'static str = "
Simple WebM screen capture. Simple WebM screen capture.

View File

@ -64,6 +64,9 @@ pub fn would_block_if_equal(old: &mut Vec<u8>, b: &[u8]) -> std::io::Result<()>
pub trait TraitCapturer { pub trait TraitCapturer {
fn set_use_yuv(&mut self, use_yuv: bool); fn set_use_yuv(&mut self, use_yuv: bool);
// We doesn't support
#[cfg(not(any(target_os = "ios")))]
fn frame<'a>(&'a mut self, timeout: std::time::Duration) -> std::io::Result<Frame<'a>>; fn frame<'a>(&'a mut self, timeout: std::time::Duration) -> std::io::Result<Frame<'a>>;
#[cfg(windows)] #[cfg(windows)]

View File

@ -1,3 +1,3 @@
pub mod capturable;
pub mod pipewire; pub mod pipewire;
mod pipewire_dbus; mod pipewire_dbus;
pub mod capturable;

View File

@ -55,7 +55,6 @@ use scrap::{
use crate::{ use crate::{
common::{self, is_keyboard_mode_supported}, common::{self, is_keyboard_mode_supported},
server::video_service::{SCRAP_X11_REF_URL, SCRAP_X11_REQUIRED},
}; };
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
@ -74,6 +73,27 @@ pub const MILLI1: Duration = Duration::from_millis(1);
pub const SEC30: Duration = Duration::from_secs(30); pub const SEC30: Duration = Duration::from_secs(30);
pub const VIDEO_QUEUE_SIZE: usize = 120; pub const VIDEO_QUEUE_SIZE: usize = 120;
pub const LOGIN_MSG_DESKTOP_NOT_INITED: &str = "Desktop env is not inited";
pub const LOGIN_MSG_DESKTOP_SESSION_NOT_READY: &str = "Desktop session not ready";
pub const LOGIN_MSG_DESKTOP_XSESSION_FAILED: &str = "Desktop xsession failed";
pub const LOGIN_MSG_DESKTOP_SESSION_ANOTHER_USER: &str = "Desktop session another user login";
pub const LOGIN_MSG_DESKTOP_XORG_NOT_FOUND: &str = "Desktop xorg not found";
// ls /usr/share/xsessions/
pub const LOGIN_MSG_DESKTOP_NO_DESKTOP: &str = "Desktop none";
pub const LOGIN_MSG_DESKTOP_SESSION_NOT_READY_PASSWORD_EMPTY: &str =
"Desktop session not ready, password empty";
pub const LOGIN_MSG_DESKTOP_SESSION_NOT_READY_PASSWORD_WRONG: &str =
"Desktop session not ready, password wrong";
pub const LOGIN_MSG_PASSWORD_EMPTY: &str = "Empty Password";
pub const LOGIN_MSG_PASSWORD_WRONG: &str = "Wrong Password";
pub const LOGIN_MSG_NO_PASSWORD_ACCESS: &str = "No Password Access";
pub const LOGIN_MSG_OFFLINE: &str = "Offline";
pub const SCRAP_UBUNTU_HIGHER_REQUIRED: &str = "Wayland requires Ubuntu 21.04 or higher version.";
pub const SCRAP_OTHER_VERSION_OR_X11_REQUIRED: &str =
"Wayland requires higher version of linux distro. Please try X11 desktop or change your OS.";
pub const SCRAP_X11_REQUIRED: &str = "x11 expected";
pub const SCRAP_X11_REF_URL: &str = "https://rustdesk.com/docs/en/manual/linux/#x11-required";
/// Client of the remote desktop. /// Client of the remote desktop.
pub struct Client; pub struct Client;
@ -1970,49 +1990,49 @@ struct LoginErrorMsgBox {
lazy_static::lazy_static! { lazy_static::lazy_static! {
static ref LOGIN_ERROR_MAP: Arc<HashMap<&'static str, LoginErrorMsgBox>> = { static ref LOGIN_ERROR_MAP: Arc<HashMap<&'static str, LoginErrorMsgBox>> = {
use hbb_common::config::LINK_HEADLESS_LINUX_SUPPORT; use hbb_common::config::LINK_HEADLESS_LINUX_SUPPORT;
let map = HashMap::from([(crate::server::LOGIN_MSG_DESKTOP_SESSION_NOT_READY, LoginErrorMsgBox{ let map = HashMap::from([(LOGIN_MSG_DESKTOP_SESSION_NOT_READY, LoginErrorMsgBox{
msgtype: "session-login", msgtype: "session-login",
title: "", title: "",
text: "", text: "",
link: "", link: "",
try_again: true, try_again: true,
}), (crate::server::LOGIN_MSG_DESKTOP_XSESSION_FAILED, LoginErrorMsgBox{ }), (LOGIN_MSG_DESKTOP_XSESSION_FAILED, LoginErrorMsgBox{
msgtype: "session-re-login", msgtype: "session-re-login",
title: "", title: "",
text: "", text: "",
link: "", link: "",
try_again: true, try_again: true,
}), (crate::server::LOGIN_MSG_DESKTOP_SESSION_ANOTHER_USER, LoginErrorMsgBox{ }), (LOGIN_MSG_DESKTOP_SESSION_ANOTHER_USER, LoginErrorMsgBox{
msgtype: "info-nocancel", msgtype: "info-nocancel",
title: "another_user_login_title_tip", title: "another_user_login_title_tip",
text: "another_user_login_text_tip", text: "another_user_login_text_tip",
link: "", link: "",
try_again: false, try_again: false,
}), (crate::server::LOGIN_MSG_DESKTOP_XORG_NOT_FOUND, LoginErrorMsgBox{ }), (LOGIN_MSG_DESKTOP_XORG_NOT_FOUND, LoginErrorMsgBox{
msgtype: "info-nocancel", msgtype: "info-nocancel",
title: "xorg_not_found_title_tip", title: "xorg_not_found_title_tip",
text: "xorg_not_found_text_tip", text: "xorg_not_found_text_tip",
link: LINK_HEADLESS_LINUX_SUPPORT, link: LINK_HEADLESS_LINUX_SUPPORT,
try_again: true, try_again: true,
}), (crate::server::LOGIN_MSG_DESKTOP_NO_DESKTOP, LoginErrorMsgBox{ }), (LOGIN_MSG_DESKTOP_NO_DESKTOP, LoginErrorMsgBox{
msgtype: "info-nocancel", msgtype: "info-nocancel",
title: "no_desktop_title_tip", title: "no_desktop_title_tip",
text: "no_desktop_text_tip", text: "no_desktop_text_tip",
link: LINK_HEADLESS_LINUX_SUPPORT, link: LINK_HEADLESS_LINUX_SUPPORT,
try_again: true, try_again: true,
}), (crate::server::LOGIN_MSG_DESKTOP_SESSION_NOT_READY_PASSWORD_EMPTY, LoginErrorMsgBox{ }), (LOGIN_MSG_DESKTOP_SESSION_NOT_READY_PASSWORD_EMPTY, LoginErrorMsgBox{
msgtype: "session-login-password", msgtype: "session-login-password",
title: "", title: "",
text: "", text: "",
link: "", link: "",
try_again: true, try_again: true,
}), (crate::server::LOGIN_MSG_DESKTOP_SESSION_NOT_READY_PASSWORD_WRONG, LoginErrorMsgBox{ }), (LOGIN_MSG_DESKTOP_SESSION_NOT_READY_PASSWORD_WRONG, LoginErrorMsgBox{
msgtype: "session-login-re-password", msgtype: "session-login-re-password",
title: "", title: "",
text: "", text: "",
link: "", link: "",
try_again: true, try_again: true,
}), (crate::server::LOGIN_MSG_NO_PASSWORD_ACCESS, LoginErrorMsgBox{ }), (LOGIN_MSG_NO_PASSWORD_ACCESS, LoginErrorMsgBox{
msgtype: "wait-remote-accept-nook", msgtype: "wait-remote-accept-nook",
title: "Prompt", title: "Prompt",
text: "Please wait for the remote side to accept your session request...", text: "Please wait for the remote side to accept your session request...",
@ -2030,11 +2050,11 @@ pub fn handle_login_error(
err: &str, err: &str,
interface: &impl Interface, interface: &impl Interface,
) -> bool { ) -> bool {
if err == crate::server::LOGIN_MSG_PASSWORD_EMPTY { if err == LOGIN_MSG_PASSWORD_EMPTY {
lc.write().unwrap().password = Default::default(); lc.write().unwrap().password = Default::default();
interface.msgbox("input-password", "Password Required", "", ""); interface.msgbox("input-password", "Password Required", "", "");
true true
} else if err == crate::server::LOGIN_MSG_PASSWORD_WRONG { } else if err == LOGIN_MSG_PASSWORD_WRONG {
lc.write().unwrap().password = Default::default(); lc.write().unwrap().password = Default::default();
interface.msgbox("re-input-password", err, "Do you want to enter again?", ""); interface.msgbox("re-input-password", err, "Do you want to enter again?", "");
true true

View File

@ -36,6 +36,7 @@ use crate::client::{
use crate::common::{self, 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};
#[cfg(not(any(target_os = "ios")))]
use crate::{audio_service, ConnInner, CLIENT_SERVER}; use crate::{audio_service, ConnInner, CLIENT_SERVER};
use crate::{client::Data, client::Interface}; use crate::{client::Data, client::Interface};
@ -303,60 +304,65 @@ impl<T: InvokeUiSession> Remote<T> {
if let Some(device) = default_sound_device { if let Some(device) = default_sound_device {
set_sound_input(device); set_sound_input(device);
} }
// Create a channel to receive error or closed message // iOS does not have this server.
let (tx, rx) = std::sync::mpsc::channel(); #[cfg(not(any(target_os = "ios")))]
let (tx_audio_data, mut rx_audio_data) = hbb_common::tokio::sync::mpsc::unbounded_channel(); {
// Create a stand-alone inner, add subscribe to audio service // Create a channel to receive error or closed message
let conn_id = CLIENT_SERVER.write().unwrap().get_new_id(); let (tx, rx) = std::sync::mpsc::channel();
let client_conn_inner = ConnInner::new(conn_id.clone(), Some(tx_audio_data), None); let (tx_audio_data, mut rx_audio_data) = hbb_common::tokio::sync::mpsc::unbounded_channel();
// now we subscribe // Create a stand-alone inner, add subscribe to audio service
CLIENT_SERVER.write().unwrap().subscribe( let conn_id = CLIENT_SERVER.write().unwrap().get_new_id();
audio_service::NAME, let client_conn_inner = ConnInner::new(conn_id.clone(), Some(tx_audio_data), None);
client_conn_inner.clone(), // now we subscribe
true, CLIENT_SERVER.write().unwrap().subscribe(
); audio_service::NAME,
let tx_audio = self.sender.clone(); client_conn_inner.clone(),
std::thread::spawn(move || { true,
loop { );
// check if client is closed let tx_audio = self.sender.clone();
match rx.try_recv() { std::thread::spawn(move || {
Ok(_) | Err(std::sync::mpsc::TryRecvError::Disconnected) => { loop {
log::debug!("Exit voice call audio service of client"); // check if client is closed
// unsubscribe match rx.try_recv() {
CLIENT_SERVER.write().unwrap().subscribe( Ok(_) | Err(std::sync::mpsc::TryRecvError::Disconnected) => {
audio_service::NAME, log::debug!("Exit voice call audio service of client");
client_conn_inner, // unsubscribe
false, CLIENT_SERVER.write().unwrap().subscribe(
); audio_service::NAME,
break; client_conn_inner,
} false,
_ => {} );
} break;
match rx_audio_data.try_recv() {
Ok((_instant, msg)) => match &msg.union {
Some(message::Union::AudioFrame(frame)) => {
let mut msg = Message::new();
msg.set_audio_frame(frame.clone());
tx_audio.send(Data::Message(msg)).ok();
}
Some(message::Union::Misc(misc)) => {
let mut msg = Message::new();
msg.set_misc(misc.clone());
tx_audio.send(Data::Message(msg)).ok();
} }
_ => {} _ => {}
}, }
Err(err) => { match rx_audio_data.try_recv() {
if err == TryRecvError::Empty { Ok((_instant, msg)) => match &msg.union {
// ignore Some(message::Union::AudioFrame(frame)) => {
} else { let mut msg = Message::new();
log::debug!("Failed to record local audio channel: {}", err); msg.set_audio_frame(frame.clone());
tx_audio.send(Data::Message(msg)).ok();
}
Some(message::Union::Misc(misc)) => {
let mut msg = Message::new();
msg.set_misc(misc.clone());
tx_audio.send(Data::Message(msg)).ok();
}
_ => {}
},
Err(err) => {
if err == TryRecvError::Empty {
// ignore
} else {
log::debug!("Failed to record local audio channel: {}", err);
}
} }
} }
} }
} });
}); return Some(tx);
Some(tx) }
None
} }
async fn handle_msg_from_ui(&mut self, data: Data, peer: &mut Stream) -> bool { async fn handle_msg_from_ui(&mut self, data: Data, peer: &mut Stream) -> bool {

View File

@ -782,6 +782,7 @@ pub fn make_fd_to_json(id: i32, path: String, entries: &Vec<FileEntry>) -> Strin
/// 1. Try to send the url scheme from ipc. /// 1. Try to send the url scheme from ipc.
/// 2. If failed to send the url scheme, we open a new main window to handle this url scheme. /// 2. If failed to send the url scheme, we open a new main window to handle this url scheme.
pub fn handle_url_scheme(url: String) { pub fn handle_url_scheme(url: String) {
#[cfg(not(target_os = "ios"))]
if let Err(err) = crate::ipc::send_url_scheme(url.clone()) { if let Err(err) = crate::ipc::send_url_scheme(url.clone()) {
log::debug!("Send the url to the existing flutter process failed, {}. Let's open a new program to handle this.", err); log::debug!("Send the url to the existing flutter process failed, {}. Let's open a new program to handle this.", err);
let _ = crate::run_me(vec![url]); let _ = crate::run_me(vec![url]);
@ -801,6 +802,9 @@ pub fn decode64<T: AsRef<[u8]>>(input: T) -> Result<Vec<u8>, base64::DecodeError
} }
pub async fn get_key(sync: bool) -> String { pub async fn get_key(sync: bool) -> String {
#[cfg(target_os = "ios")]
let mut key = Config::get_option("key");
#[cfg(not(target_os = "ios"))]
let mut key = if sync { let mut key = if sync {
Config::get_option("key") Config::get_option("key")
} else { } else {

View File

@ -844,11 +844,13 @@ fn main_broadcast_message(data: &HashMap<&str, &str>) {
pub fn main_change_theme(dark: String) { pub fn main_change_theme(dark: String) {
main_broadcast_message(&HashMap::from([("name", "theme"), ("dark", &dark)])); main_broadcast_message(&HashMap::from([("name", "theme"), ("dark", &dark)]));
#[cfg(not(any(target_os = "ios")))]
send_to_cm(&crate::ipc::Data::Theme(dark)); send_to_cm(&crate::ipc::Data::Theme(dark));
} }
pub fn main_change_language(lang: String) { pub fn main_change_language(lang: String) {
main_broadcast_message(&HashMap::from([("name", "language"), ("lang", &lang)])); main_broadcast_message(&HashMap::from([("name", "language"), ("lang", &lang)]));
#[cfg(not(any(target_os = "ios")))]
send_to_cm(&crate::ipc::Data::Language(lang)); send_to_cm(&crate::ipc::Data::Language(lang));
} }
@ -1138,6 +1140,8 @@ pub fn main_get_mouse_time() -> f64 {
} }
pub fn main_wol(id: String) { pub fn main_wol(id: String) {
// TODO: move send_wol outside.
#[cfg(not(any(target_os = "ios")))]
crate::lan::send_wol(id) crate::lan::send_wol(id)
} }
@ -1147,10 +1151,12 @@ pub fn main_create_shortcut(_id: String) {
} }
pub fn cm_send_chat(conn_id: i32, msg: String) { pub fn cm_send_chat(conn_id: i32, msg: String) {
#[cfg(not(any(target_os = "ios")))]
crate::ui_cm_interface::send_chat(conn_id, msg); crate::ui_cm_interface::send_chat(conn_id, msg);
} }
pub fn cm_login_res(conn_id: i32, res: bool) { pub fn cm_login_res(conn_id: i32, res: bool) {
#[cfg(not(any(target_os = "ios")))]
if res { if res {
crate::ui_cm_interface::authorize(conn_id); crate::ui_cm_interface::authorize(conn_id);
} else { } else {
@ -1159,22 +1165,29 @@ pub fn cm_login_res(conn_id: i32, res: bool) {
} }
pub fn cm_close_connection(conn_id: i32) { pub fn cm_close_connection(conn_id: i32) {
#[cfg(not(any(target_os = "ios")))]
crate::ui_cm_interface::close(conn_id); crate::ui_cm_interface::close(conn_id);
} }
pub fn cm_remove_disconnected_connection(conn_id: i32) { pub fn cm_remove_disconnected_connection(conn_id: i32) {
#[cfg(not(any(target_os = "ios")))]
crate::ui_cm_interface::remove(conn_id); crate::ui_cm_interface::remove(conn_id);
} }
pub fn cm_check_click_time(conn_id: i32) { pub fn cm_check_click_time(conn_id: i32) {
#[cfg(not(any(target_os = "ios")))]
crate::ui_cm_interface::check_click_time(conn_id) crate::ui_cm_interface::check_click_time(conn_id)
} }
pub fn cm_get_click_time() -> f64 { pub fn cm_get_click_time() -> f64 {
crate::ui_cm_interface::get_click_time() as _ #[cfg(not(any(target_os = "ios")))]
return crate::ui_cm_interface::get_click_time() as _;
#[cfg(any(target_os = "ios"))]
return 0 as _;
} }
pub fn cm_switch_permission(conn_id: i32, name: String, enabled: bool) { pub fn cm_switch_permission(conn_id: i32, name: String, enabled: bool) {
#[cfg(not(any(target_os = "ios")))]
crate::ui_cm_interface::switch_permission(conn_id, name, enabled) crate::ui_cm_interface::switch_permission(conn_id, name, enabled)
} }
@ -1183,10 +1196,12 @@ pub fn cm_can_elevate() -> SyncReturn<bool> {
} }
pub fn cm_elevate_portable(conn_id: i32) { pub fn cm_elevate_portable(conn_id: i32) {
#[cfg(not(any(target_os = "ios")))]
crate::ui_cm_interface::elevate_portable(conn_id); crate::ui_cm_interface::elevate_portable(conn_id);
} }
pub fn cm_switch_back(conn_id: i32) { pub fn cm_switch_back(conn_id: i32) {
#[cfg(not(any(target_os = "ios")))]
crate::ui_cm_interface::switch_back(conn_id); crate::ui_cm_interface::switch_back(conn_id);
} }
@ -1222,6 +1237,7 @@ fn handle_query_onlines(onlines: Vec<String>, offlines: Vec<String>) {
} }
pub fn query_onlines(ids: Vec<String>) { pub fn query_onlines(ids: Vec<String>) {
#[cfg(not(any(target_os = "ios")))]
crate::rendezvous_mediator::query_online_states(ids, handle_query_onlines) crate::rendezvous_mediator::query_online_states(ids, handle_query_onlines)
} }

View File

@ -6,12 +6,13 @@ use hbb_common::{
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::{json, Value}; use serde_json::{json, Value};
#[cfg(not(any(target_os = "ios")))]
use crate::Connection; use crate::Connection;
const TIME_HEARTBEAT: Duration = Duration::from_secs(30); const TIME_HEARTBEAT: Duration = Duration::from_secs(30);
const TIME_CONN: Duration = Duration::from_secs(3); const TIME_CONN: Duration = Duration::from_secs(3);
#[cfg(not(any(target_os = "ios")))]
lazy_static::lazy_static! { 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());
} }
@ -21,10 +22,12 @@ pub fn start() {
let _sender = SENDER.lock().unwrap(); let _sender = SENDER.lock().unwrap();
} }
#[cfg(not(target_os = "ios"))]
pub fn signal_receiver() -> broadcast::Receiver<Vec<i32>> { pub fn signal_receiver() -> broadcast::Receiver<Vec<i32>> {
SENDER.lock().unwrap().subscribe() SENDER.lock().unwrap().subscribe()
} }
#[cfg(not(any(target_os = "ios")))]
fn start_hbbs_sync() -> broadcast::Sender<Vec<i32>> { fn start_hbbs_sync() -> broadcast::Sender<Vec<i32>> {
let (tx, _rx) = broadcast::channel::<Vec<i32>>(16); let (tx, _rx) = broadcast::channel::<Vec<i32>>(16);
std::thread::spawn(move || start_hbbs_sync_async()); std::thread::spawn(move || start_hbbs_sync_async());
@ -37,6 +40,7 @@ pub struct StrategyOptions {
pub extra: HashMap<String, String>, pub extra: HashMap<String, String>,
} }
#[cfg(not(any(target_os = "ios")))]
#[tokio::main(flavor = "current_thread")] #[tokio::main(flavor = "current_thread")]
async fn start_hbbs_sync_async() { async fn start_hbbs_sync_async() {
tokio::spawn(async move { tokio::spawn(async move {

View File

@ -1,7 +1,7 @@
#![cfg_attr( #![cfg_attr(
all(not(debug_assertions), target_os = "windows"), all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows" windows_subsystem = "windows"
)] )]
use librustdesk::*; use librustdesk::*;

View File

@ -65,22 +65,6 @@ lazy_static::lazy_static! {
pub static CLICK_TIME: AtomicI64 = AtomicI64::new(0); pub static CLICK_TIME: AtomicI64 = AtomicI64::new(0);
pub static MOUSE_MOVE_TIME: AtomicI64 = AtomicI64::new(0); pub static MOUSE_MOVE_TIME: AtomicI64 = AtomicI64::new(0);
pub const LOGIN_MSG_DESKTOP_NOT_INITED: &str = "Desktop env is not inited";
pub const LOGIN_MSG_DESKTOP_SESSION_NOT_READY: &str = "Desktop session not ready";
pub const LOGIN_MSG_DESKTOP_XSESSION_FAILED: &str = "Desktop xsession failed";
pub const LOGIN_MSG_DESKTOP_SESSION_ANOTHER_USER: &str = "Desktop session another user login";
pub const LOGIN_MSG_DESKTOP_XORG_NOT_FOUND: &str = "Desktop xorg not found";
// ls /usr/share/xsessions/
pub const LOGIN_MSG_DESKTOP_NO_DESKTOP: &str = "Desktop none";
pub const LOGIN_MSG_DESKTOP_SESSION_NOT_READY_PASSWORD_EMPTY: &str =
"Desktop session not ready, password empty";
pub const LOGIN_MSG_DESKTOP_SESSION_NOT_READY_PASSWORD_WRONG: &str =
"Desktop session not ready, password wrong";
pub const LOGIN_MSG_PASSWORD_EMPTY: &str = "Empty Password";
pub const LOGIN_MSG_PASSWORD_WRONG: &str = "Wrong Password";
pub const LOGIN_MSG_NO_PASSWORD_ACCESS: &str = "No Password Access";
pub const LOGIN_MSG_OFFLINE: &str = "Offline";
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct ConnInner { pub struct ConnInner {
id: i32, id: i32,

View File

@ -46,12 +46,6 @@ use std::{
time::{self, Duration, Instant}, time::{self, Duration, Instant},
}; };
pub const SCRAP_UBUNTU_HIGHER_REQUIRED: &str = "Wayland requires Ubuntu 21.04 or higher version.";
pub const SCRAP_OTHER_VERSION_OR_X11_REQUIRED: &str =
"Wayland requires higher version of linux distro. Please try X11 desktop or change your OS.";
pub const SCRAP_X11_REQUIRED: &str = "x11 expected";
pub const SCRAP_X11_REF_URL: &str = "https://rustdesk.com/docs/en/manual/linux/#x11-required";
pub const NAME: &'static str = "video"; pub const NAME: &'static str = "video";
lazy_static::lazy_static! { lazy_static::lazy_static! {

View File

@ -17,6 +17,7 @@ use serde_derive::Serialize;
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
use crate::ipc::Connection; use crate::ipc::Connection;
#[cfg(not(any(target_os = "android", target_os = "ios")))]
use crate::ipc::{self, Data}; use crate::ipc::{self, Data};
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
use hbb_common::tokio::sync::mpsc::unbounded_channel; use hbb_common::tokio::sync::mpsc::unbounded_channel;
@ -56,6 +57,7 @@ pub struct Client {
pub in_voice_call: bool, pub in_voice_call: bool,
pub incoming_voice_call: bool, pub incoming_voice_call: bool,
#[serde(skip)] #[serde(skip)]
#[cfg(not(any(target_os = "ios")))]
tx: UnboundedSender<Data>, tx: UnboundedSender<Data>,
} }
@ -129,6 +131,7 @@ impl<T: InvokeUiCM> ConnectionManager<T> {
restart: bool, restart: bool,
recording: bool, recording: bool,
from_switch: bool, from_switch: bool,
#[cfg(not(any(target_os = "ios")))]
tx: mpsc::UnboundedSender<Data>, tx: mpsc::UnboundedSender<Data>,
) { ) {
let client = Client { let client = Client {
@ -146,7 +149,8 @@ impl<T: InvokeUiCM> ConnectionManager<T> {
restart, restart,
recording, recording,
from_switch, from_switch,
tx, #[cfg(not(any(target_os = "ios")))]
_tx,
in_voice_call: false, in_voice_call: false,
incoming_voice_call: false, incoming_voice_call: false,
}; };
@ -222,6 +226,7 @@ impl<T: InvokeUiCM> ConnectionManager<T> {
} }
#[inline] #[inline]
#[cfg(not(any(target_os = "ios")))]
pub fn check_click_time(id: i32) { pub fn check_click_time(id: i32) {
if let Some(client) = CLIENTS.read().unwrap().get(&id) { if let Some(client) = CLIENTS.read().unwrap().get(&id) {
allow_err!(client.tx.send(Data::ClickTime(0))); allow_err!(client.tx.send(Data::ClickTime(0)));
@ -234,6 +239,7 @@ pub fn get_click_time() -> i64 {
} }
#[inline] #[inline]
#[cfg(not(any(target_os = "ios")))]
pub fn authorize(id: i32) { pub fn authorize(id: i32) {
if let Some(client) = CLIENTS.write().unwrap().get_mut(&id) { if let Some(client) = CLIENTS.write().unwrap().get_mut(&id) {
client.authorized = true; client.authorized = true;
@ -242,6 +248,7 @@ pub fn authorize(id: i32) {
} }
#[inline] #[inline]
#[cfg(not(any(target_os = "ios")))]
pub fn close(id: i32) { pub fn close(id: i32) {
if let Some(client) = CLIENTS.read().unwrap().get(&id) { if let Some(client) = CLIENTS.read().unwrap().get(&id) {
allow_err!(client.tx.send(Data::Close)); allow_err!(client.tx.send(Data::Close));
@ -255,6 +262,7 @@ pub fn remove(id: i32) {
// server mode send chat to peer // server mode send chat to peer
#[inline] #[inline]
#[cfg(not(any(target_os = "ios")))]
pub fn send_chat(id: i32, text: String) { pub fn send_chat(id: i32, text: String) {
let clients = CLIENTS.read().unwrap(); let clients = CLIENTS.read().unwrap();
if let Some(client) = clients.get(&id) { if let Some(client) = clients.get(&id) {
@ -263,6 +271,7 @@ pub fn send_chat(id: i32, text: String) {
} }
#[inline] #[inline]
#[cfg(not(any(target_os = "ios")))]
pub fn switch_permission(id: i32, name: String, enabled: bool) { pub fn switch_permission(id: i32, name: String, enabled: bool) {
if let Some(client) = CLIENTS.read().unwrap().get(&id) { if let Some(client) = CLIENTS.read().unwrap().get(&id) {
allow_err!(client.tx.send(Data::SwitchPermission { name, enabled })); allow_err!(client.tx.send(Data::SwitchPermission { name, enabled }));
@ -285,6 +294,7 @@ pub fn get_clients_length() -> usize {
#[inline] #[inline]
#[cfg(feature = "flutter")] #[cfg(feature = "flutter")]
#[cfg(not(any(target_os = "ios")))]
pub fn switch_back(id: i32) { pub fn switch_back(id: i32) {
if let Some(client) = CLIENTS.read().unwrap().get(&id) { if let Some(client) = CLIENTS.read().unwrap().get(&id) {
allow_err!(client.tx.send(Data::SwitchSidesBack)); allow_err!(client.tx.send(Data::SwitchSidesBack));
@ -594,6 +604,7 @@ pub async fn start_listen<T: InvokeUiCM>(
cm.remove_connection(current_id, true); cm.remove_connection(current_id, true);
} }
#[cfg(not(any(target_os = "ios")))]
async fn handle_fs(fs: ipc::FS, write_jobs: &mut Vec<fs::TransferJob>, tx: &UnboundedSender<Data>) { async fn handle_fs(fs: ipc::FS, write_jobs: &mut Vec<fs::TransferJob>, tx: &UnboundedSender<Data>) {
match fs { match fs {
ipc::FS::ReadDir { ipc::FS::ReadDir {
@ -739,6 +750,7 @@ async fn handle_fs(fs: ipc::FS, write_jobs: &mut Vec<fs::TransferJob>, tx: &Unbo
} }
} }
#[cfg(not(any(target_os = "ios")))]
async fn read_dir(dir: &str, include_hidden: bool, tx: &UnboundedSender<Data>) { async fn read_dir(dir: &str, include_hidden: bool, tx: &UnboundedSender<Data>) {
let path = { let path = {
if dir.is_empty() { if dir.is_empty() {
@ -756,6 +768,7 @@ async fn read_dir(dir: &str, include_hidden: bool, tx: &UnboundedSender<Data>) {
} }
} }
#[cfg(not(any(target_os = "ios")))]
async fn handle_result<F: std::fmt::Display, S: std::fmt::Display>( async fn handle_result<F: std::fmt::Display, S: std::fmt::Display>(
res: std::result::Result<std::result::Result<(), F>, S>, res: std::result::Result<std::result::Result<(), F>, S>,
id: i32, id: i32,
@ -775,6 +788,7 @@ async fn handle_result<F: std::fmt::Display, S: std::fmt::Display>(
} }
} }
#[cfg(not(any(target_os = "ios")))]
async fn remove_file(path: String, id: i32, file_num: i32, tx: &UnboundedSender<Data>) { async fn remove_file(path: String, id: i32, file_num: i32, tx: &UnboundedSender<Data>) {
handle_result( handle_result(
spawn_blocking(move || fs::remove_file(&path)).await, spawn_blocking(move || fs::remove_file(&path)).await,
@ -785,6 +799,7 @@ async fn remove_file(path: String, id: i32, file_num: i32, tx: &UnboundedSender<
.await; .await;
} }
#[cfg(not(any(target_os = "ios")))]
async fn create_dir(path: String, id: i32, tx: &UnboundedSender<Data>) { async fn create_dir(path: String, id: i32, tx: &UnboundedSender<Data>) {
handle_result( handle_result(
spawn_blocking(move || fs::create_dir(&path)).await, spawn_blocking(move || fs::create_dir(&path)).await,
@ -795,6 +810,7 @@ async fn create_dir(path: String, id: i32, tx: &UnboundedSender<Data>) {
.await; .await;
} }
#[cfg(not(any(target_os = "ios")))]
async fn remove_dir(path: String, id: i32, recursive: bool, tx: &UnboundedSender<Data>) { async fn remove_dir(path: String, id: i32, recursive: bool, tx: &UnboundedSender<Data>) {
let path = fs::get_path(&path); let path = fs::get_path(&path);
handle_result( handle_result(
@ -813,6 +829,7 @@ async fn remove_dir(path: String, id: i32, recursive: bool, tx: &UnboundedSender
.await; .await;
} }
#[cfg(not(any(target_os = "ios")))]
fn send_raw(msg: Message, tx: &UnboundedSender<Data>) { fn send_raw(msg: Message, tx: &UnboundedSender<Data>) {
match msg.write_to_bytes() { match msg.write_to_bytes() {
Ok(bytes) => { Ok(bytes) => {
@ -859,6 +876,8 @@ pub fn elevate_portable(_id: i32) {
#[inline] #[inline]
pub fn handle_incoming_voice_call(id: i32, accept: bool) { pub fn handle_incoming_voice_call(id: i32, accept: bool) {
if let Some(client) = CLIENTS.read().unwrap().get(&id) { if let Some(client) = CLIENTS.read().unwrap().get(&id) {
// Not handled in iOS yet.
#[cfg(not(any(target_os = "ios")))]
allow_err!(client.tx.send(Data::VoiceCallResponse(accept))); allow_err!(client.tx.send(Data::VoiceCallResponse(accept)));
}; };
} }
@ -867,6 +886,8 @@ pub fn handle_incoming_voice_call(id: i32, accept: bool) {
#[inline] #[inline]
pub fn close_voice_call(id: i32) { pub fn close_voice_call(id: i32) {
if let Some(client) = CLIENTS.read().unwrap().get(&id) { if let Some(client) = CLIENTS.read().unwrap().get(&id) {
// Not handled in iOS yet.
#[cfg(not(any(target_os = "ios")))]
allow_err!(client.tx.send(Data::CloseVoiceCall("".to_owned()))); allow_err!(client.tx.send(Data::CloseVoiceCall("".to_owned())));
}; };
} }

View File

@ -26,7 +26,10 @@ use hbb_common::{
#[cfg(feature = "flutter")] #[cfg(feature = "flutter")]
use crate::hbbs_http::account; use crate::hbbs_http::account;
use crate::{common::SOFTWARE_UPDATE_URL, ipc}; use crate::{common::SOFTWARE_UPDATE_URL};
#[cfg(not(any(target_os = "ios")))]
use crate::ipc;
type Message = RendezvousMessage; type Message = RendezvousMessage;
@ -569,6 +572,7 @@ pub fn create_shortcut(_id: String) {
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))] #[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
#[inline] #[inline]
pub fn discover() { pub fn discover() {
#[cfg(not(any(target_os = "ios")))]
std::thread::spawn(move || { std::thread::spawn(move || {
allow_err!(crate::lan::discover()); allow_err!(crate::lan::discover());
}); });
@ -922,7 +926,8 @@ pub fn option_synced() -> bool {
OPTION_SYNCED.lock().unwrap().clone() OPTION_SYNCED.lock().unwrap().clone()
} }
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))] #[cfg(any(target_os = "android", feature = "flutter"))]
#[cfg(not(any(target_os = "ios")))]
#[tokio::main(flavor = "current_thread")] #[tokio::main(flavor = "current_thread")]
pub(crate) async fn send_to_cm(data: &ipc::Data) { pub(crate) async fn send_to_cm(data: &ipc::Data) {
if let Ok(mut c) = ipc::connect(1000, "_cm").await { if let Ok(mut c) = ipc::connect(1000, "_cm").await {

View File

@ -263,7 +263,10 @@ impl<T: InvokeUiSession> Session<T> {
} }
pub fn is_xfce(&self) -> bool { pub fn is_xfce(&self) -> bool {
crate::platform::is_xfce() #[cfg(not(any(target_os = "ios")))]
return crate::platform::is_xfce();
#[cfg(any(target_os = "ios"))]
false
} }
pub fn get_supported_keyboard_modes(&self) -> Vec<KeyboardMode> { pub fn get_supported_keyboard_modes(&self) -> Vec<KeyboardMode> {
@ -526,6 +529,17 @@ impl<T: InvokeUiSession> Session<T> {
self.send(Data::Message(msg_out)); self.send(Data::Message(msg_out));
} }
#[cfg(any(target_os = "ios"))]
pub fn handle_flutter_key_event(
&self,
_name: &str,
platform_code: i32,
position_code: i32,
lock_modes: i32,
down_or_up: bool,
) {}
#[cfg(not(any(target_os = "ios")))]
pub fn handle_flutter_key_event( pub fn handle_flutter_key_event(
&self, &self,
_name: &str, _name: &str,
@ -755,6 +769,10 @@ impl<T: InvokeUiSession> Session<T> {
self.send(Data::ElevateWithLogon(username, password)); self.send(Data::ElevateWithLogon(username, password));
} }
#[cfg(any(target_os = "ios"))]
pub fn switch_sides(&self) {}
#[cfg(not(any(target_os = "ios")))]
#[tokio::main(flavor = "current_thread")] #[tokio::main(flavor = "current_thread")]
pub async fn switch_sides(&self) { pub async fn switch_sides(&self) {
match crate::ipc::connect(1000, "").await { match crate::ipc::connect(1000, "").await {